/*================================================================
*   Copyright (C) 2021 Sangfor Ltd. All rights reserved.
*   
*   文件名称：test_httplib.cpp
*   创 建 者：wudu
*   创建日期：2021年08月26日
*   描    述：
*
================================================================*/

#include <stdio.h>
#include <iostream>

#include "httplib.h"

using namespace httplib;
using namespace std;

int g_val = 100;

void Get_CallBackFunc(const Request& req, Response& resp)
{
    printf("%d\n", g_val);
    cout << req.method << endl; 
    printf("i am Get_CallBackFunc\n");

    const char* lp = "<html><h2>hello bite!</h2></html>";
    resp.set_content(lp, strlen(lp), "text/html");
}

int main()
{
    Server http_svr;
    int a = 10;
    http_svr.Get("/abc", Get_CallBackFunc);
    http_svr.Post("/111", [a](const Request& req, Response& resp){
            printf("a : %d\n", a);
            });
    http_svr.set_mount_point("/", "./web");
    http_svr.listen("0.0.0.0", 21010);
    return 0;
}
